﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 新增班组表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "GroupId",
                table: "SysAttendanceShift",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "SysAttendanceShiftGroup",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false),
                    Description = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
                    Type = table.Column<int>(type: "int", nullable: false),
                    SchedulePattern = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysAttendanceShiftGroup", x => x.ID);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysAttendanceShift_GroupId",
                table: "SysAttendanceShift",
                column: "GroupId");

            migrationBuilder.AddForeignKey(
                name: "FK_SysAttendanceShift_SysAttendanceShiftGroup_GroupId",
                table: "SysAttendanceShift",
                column: "GroupId",
                principalTable: "SysAttendanceShiftGroup",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysAttendanceShift_SysAttendanceShiftGroup_GroupId",
                table: "SysAttendanceShift");

            migrationBuilder.DropTable(
                name: "SysAttendanceShiftGroup");

            migrationBuilder.DropIndex(
                name: "IX_SysAttendanceShift_GroupId",
                table: "SysAttendanceShift");

            migrationBuilder.DropColumn(
                name: "GroupId",
                table: "SysAttendanceShift");
        }
    }
}
